<?php

	class My_Plugin_SwitchLanguage extends Zend_Controller_Plugin_Abstract
	{
	    public function preDispatch(Zend_Controller_Request_Abstract $request)
	    {

            $langSession = new Zend_Session_Namespace();
            $module = $request->getModuleName();
            $requestedLanguage   = $request->language;
            //echo $requestedLanguage .' -- '. $langSession->language;

            if (!empty($requestedLanguage) && !empty($requestedLanguage)) {
                if ($requestedLanguage != $langSession->language) {

                    $langSession->language = $requestedLanguage;

                    $redirectUri = $request->getRequestUri();

                    //Module-specific language settings
                    $this->_response->setRedirect($redirectUri);
                }

            }



		}
	}